#!/bin/bash 
set -e


TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage4}
SRC=${SRC:-/sources}

name=sgml-common
version=0.6.3

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tgz -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
	patch -Np1 -i $SRC/$name-$version-manpage-1.patch
	autoreconf -f -i

	./configure --prefix=/usr --sysconfdir=/etc
	make

	make docdir=/usr/share/doc install

	install-catalog --add /etc/sgml/sgml-ent.cat \
	    /usr/share/sgml/sgml-iso-entities-8879.1986/catalog

	install-catalog --add /etc/sgml/sgml-docbook.cat \
	    /etc/sgml/sgml-ent.cat

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
